/*
 *    Copyright (c) 2018-2025, nart All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: nart
 */
package com.nai365.nart.member.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nai365.nart.member.entity.WalletChange;
import com.nai365.nart.member.mapper.WalletChangeMapper;
import com.nai365.nart.member.service.WalletChangeService;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

/**
 * 钱包修改记录表
 *
 * @author baogs
 * @date 2022-07-07 09:47:26
 */
@Service
public class WalletChangeServiceImpl extends ServiceImpl<WalletChangeMapper, WalletChange> implements WalletChangeService {

	@Override
	public WalletChange findWalletChangeByUserId(Long userId) {
		LambdaQueryWrapper<WalletChange> walletChangeLambdaQueryWrapper = new LambdaQueryWrapper<>();
		walletChangeLambdaQueryWrapper.eq(WalletChange::getUserId,userId);
		return this.getOne(walletChangeLambdaQueryWrapper);
	}

	@Override
	public Boolean updateWalletChange(Long userId, BigDecimal rmb) {
		LambdaUpdateWrapper<WalletChange> walletChangeLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
		walletChangeLambdaUpdateWrapper.set(WalletChange::getRmbValue,rmb).eq(WalletChange::getUserId,userId);
		return this.update(walletChangeLambdaUpdateWrapper);
	}
}
